package xby.study.noxmlweb.servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 精确匹配: http://host:port/<contextroot>/
 *
 */
@WebServlet(name = "welcomeServlet", value = "")
public class WelcomeServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Welcome to my world !";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // 欢迎页
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}
